﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TextEditor.TextDocument.Control
{
    public partial class frmSetMinOrMaxNumb : Form
    {
        public frmSetMinOrMaxNumb()
        {
            InitializeComponent();
        }

        public delegate void BackInputValue(float float1, float float2);
        public BackInputValue OnBackValue;
        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            rotation = true;
            float f = CheckIsFloat(this.textBox1.Text.Trim());
            float f2 = CheckIsFloat(this.textBox2.Text.Trim());
            if (f > f2)
            {
                MessageBox.Show("最小值不能大于最大值！");
                return;
            }

            if (OnBackValue != null)
            {
                OnBackValue(f, f2);
            }
            this.Close();
        }

        public bool rotation = false;

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        public static float CheckIsFloat(string inputValue)
        {
            float f;
            float.TryParse(inputValue, out f);
            return f;
        }
    }
}
